package com.project.MQconfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {
    @Autowired
    CachingConnectionFactory factory;
    //rabbitmq模板
    @Bean(value = "rabbitTemplate")
    public RabbitTemplate rabbitTemplate(){
        return new RabbitTemplate(factory);
    }

    @Bean
    public Queue queue2(){
        return new Queue("MonitorQueue2");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange2(){
        return new DirectExchange("monitorExchange2");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange2(Queue queue2,DirectExchange directExchange2){
        return BindingBuilder.bind(queue2).to(directExchange2).with("monitorRouting2");
    }

    @Bean
    public Queue queue0(){
        return new Queue("MonitorQueue0");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange0(){
        return new DirectExchange("monitorExchange0");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange0(Queue queue0,DirectExchange directExchange0){
        return BindingBuilder.bind(queue0).to(directExchange0).with("monitorRouting0");
    }

    @Bean
    public Queue queue1(){
        return new Queue("MonitorQueue1");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange1(){
        return new DirectExchange("monitorExchange1");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange1(Queue queue1,DirectExchange directExchange1){
        return BindingBuilder.bind(queue1).to(directExchange1).with("monitorRouting1");
    }


    @Bean
    public Queue queue3(){
        return new Queue("MonitorQueue3");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange3(){
        return new DirectExchange("monitorExchange3");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange3(Queue queue3,DirectExchange directExchange3){
        return BindingBuilder.bind(queue3).to(directExchange3).with("monitorRouting3");
    }


    @Bean
    public Queue queue4(){
        return new Queue("MonitorQueue4");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange4(){
        return new DirectExchange("monitorExchange4");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange4(Queue queue4,DirectExchange directExchange4){
        return BindingBuilder.bind(queue4).to(directExchange4).with("monitorRouting4");
    }

    @Bean
    public Queue queue5(){
        return new Queue("MonitorQueue5");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange5(){
        return new DirectExchange("monitorExchange5");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange5(Queue queue5,DirectExchange directExchange5){
        return BindingBuilder.bind(queue5).to(directExchange5).with("monitorRouting5");
    }


    @Bean
    public Queue queue6(){
        return new Queue("MonitorQueue6");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange6(){
        return new DirectExchange("monitorExchange6");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange6(Queue queue6,DirectExchange directExchange6){
        return BindingBuilder.bind(queue6).to(directExchange6).with("monitorRouting6");
    }


    @Bean
    public Queue queue7(){
        return new Queue("MonitorQueue7");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange7(){
        return new DirectExchange("monitorExchange7");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange7(Queue queue7,DirectExchange directExchange7){
        return BindingBuilder.bind(queue7).to(directExchange7).with("monitorRouting7");
    }


    @Bean
    public Queue queue8(){
        return new Queue("MonitorQueue8");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange8(){
        return new DirectExchange("monitorExchange8");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange8(Queue queue8,DirectExchange directExchange8){
        return BindingBuilder.bind(queue8).to(directExchange8).with("monitorRouting8");
    }

    @Bean
    public Queue queue9(){
        return new Queue("MonitorQueue9");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchange9(){
        return new DirectExchange("monitorExchange9");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchange9(Queue queue9,DirectExchange directExchange9){
        return BindingBuilder.bind(queue9).to(directExchange9).with("monitorRouting9");
    }


    @Bean
    public Queue queueNew(){
        return new Queue("MonitorQueueNew");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchangeNew(){
        return new DirectExchange("monitorExchangeNew");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchangeNew(Queue queueNew,DirectExchange directExchangeNew){
        return BindingBuilder.bind(queueNew).to(directExchangeNew).with("monitorRoutingNew");
    }


    @Bean
    public Queue queueWithdraw(){
        return new Queue("MonitorQueueWithdraw");
    }
    //创建交换机，默认交换机，主题交换机，扇形交换机，头交换机
    //默认交换机
    @Bean
    public DirectExchange directExchangeWithdraw(){
        return new DirectExchange("monitorExchangeWithdraw");
    }


    //把对列绑定到交换机
    @Bean
    public Binding queueOneToDirectExchangeWithdraw(Queue queueWithdraw,DirectExchange directExchangeWithdraw){
        return BindingBuilder.bind(queueWithdraw).to(directExchangeWithdraw).with("monitorRoutingWithdraw");
    }
}
